const Mock = require('mockjs')

const Random = Mock.Random

let Result = {
  code: 200,
  msg: '操作成功',
  data: null
}

Mock.mock('/captcha', 'get', () => {
  Result.data = {
    token: Random.string(32),
    captchaImg: Random.dataImage('120x40', 'p7n5w')
  }

  return Result
})

Mock.mock('/login', 'post', () => {


  return Result
})

Mock.mock('/sys/userInfo', 'get', () => {

  Result.data = {
    id: "1",
    username: "管理员",
    avatar: "https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
  }

  return Result
})

Mock.mock('/logout', 'post', () => {

  return Result
})

// 获取用户菜单
Mock.mock('/sys/menu/nav', 'get', () => {

  let nav = [/*
    {
      name: 'Percenter',
      title: '首页',
      icon: 'el-icon-s-custom',
      component: '',
      path: '',
      children: []
    }, */
    {
      name: 'Percenter',
      title: '个人中心',
      icon: 'el-icon-s-custom',
      component: '',
      path: '',
      children: [
        {
          name: 'UserInfo',
          title: '个人信息',
          icon: 'el-icon-s-custom',
          path: '/sys/userinfo',
          component: 'PersonCenter/SysUserInfo',
        },
        {
          name: 'ChangePwd',
          title: '修改密码',
          icon: 'el-icon-rank',
          path: '/sys/changepwd',
          component: 'PersonCenter/SysChangePwd',
        }
      ]
    },
    {
      name: 'Needtest',
      title: '需检人员',
      icon: 'el-icon-coin',
      path: '',
      component: '',
      children: [
        {
          name: 'NeedtestMan',
          title: '需检人员信息',
          icon: 'el-icon-rank',
          path: '/sys/needtestman',
          component: 'Needtest/SysNeedtestMan',
        }
      ]
    },
    {
      name: 'TestManagement',
      title: '检测管理',
      icon: 'el-icon-s-order',
      path: '',
      component: '',
      children: [
        {
          name: 'ActivityManage',
          title: '活动管理',
          icon: 'el-icon-rank',
          path: '/sys/activitymanage',
          component: 'TestManagement/SysActivityManage',
        },
        {
          name: 'AddressManage',
          title: '地点管理',
          icon: 'el-icon-rank',
          path: '/sys/addressmanage',
          component: 'TestManagement/SysAddressManage',
        },
        {
          name: 'NotesManage',
          title: '记录管理',
          icon: 'el-icon-rank',
          path: '/sys/notesmanage',
          component: 'TestManagement/SysNotesManage',
        }
      ]
    },
    {
      name: 'Authority',
      title: '权限管理',
      icon: 'el-icon-postcard',
      path: '',
      component: '',
      children: [
        {
          name: 'AuthInfo',
          title: '权限信息',
          icon: 'el-icon-rank',
          path: '/sys/authinfo',
          component: 'Authority/SysAuthInfo',
        }
      ]
    },
  ]

  Result.data = {
    nav: nav,
  }

  return Result
})

// 地点管理
Mock.mock(RegExp('/sys/address/list*'), 'get', () => {
  Result.data = {
    addresslist: [
      {
        addressId: 1,
        addressName: "赣南医学院(黄金校区)-操场",
        activitiesAddressId: 1,
        addressNumber: "1号窗口",
        testdata: "2022-08-01",
        testperiod: "10:00-10:30",
        userid: 1,
        username: "小明",
        phone: 123456,
        usernum: 1111111,
        status: 1
      },
      {
        addressId: 2,
        addressName: "赣南医学院(黄金校区)-操场",
        activitiesAddressId: 2,
        addressNumber: "2号窗口",
        testdata: "2022-08-01",
        testperiod: "11:00-11:30",
        userid: 2,
        username: "小红",
        phone: 323456,
        usernum: 222222,
        status: 0
      },
      {
        addressId: 3,
        addressName: "赣南医学院(黄金校区)-篮球场",
        activitiesAddressId: 3,
        addressNumber: "3号窗口",
        testdata: "2022-08-02",
        testperiod: "11:00-11:30",
        userid: 2,
        username: "小黑",
        phone: 323456,
        usernum: 222222,
        status: 0
      }
    ],
    datafilters: [{ text: '2022-08-01', value: '2022-08-01' }, { text: '2022-08-02', value: '2022-08-02' }],
    addressfilters: [{ text: '赣南医学院(黄金校区)-操场', value: '赣南医学院(黄金校区)-操场' }, { text: '赣南医学院(黄金校区)-篮球场', value: '赣南医学院(黄金校区)-篮球场' }],
    total: 3,
    size: 10,
    current: 1,
  }

  return Result
})

Mock.mock(RegExp('/sys/address/*'), 'post', () => {
  return Result
})

Mock.mock(RegExp('/sys/address/info/*'), 'get', () => {

  Result.data = {
    addressId: 3,
    addressName: "赣南医学院(黄金校区)-篮球场",
    activitiesAddressId: 3,
    addressNumber: "3号窗口",
    testdata: "2022-08-02",
    testperiod: "11:00-11:30",
    userid: 2,
    username: "小黑",
    phone: 323456,
    usernum: 222222,
    status: 0
  }
  return Result
})
